package com.c2soft.ncmxtradeX.webApp;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

import com.c2soft.ncmxtradeX.webApp.security.RoleBasedAuthenticationSuccessRedirectHandler;

@Configuration
public class DataSourceConfig {

	@Bean
	public DataSource datasSource() {
		DriverManagerDataSource dataSource = new DriverManagerDataSource();

		dataSource.setDriverClassName("com.mysql.jdbc.Driver");
		dataSource.setUrl("jdbc:mysql://localhost:3306/ncmxDb");
		dataSource.setUsername("ncmx");
		dataSource.setPassword("password");
		return dataSource;
	}

	@Bean
	public AuthenticationSuccessHandler successHandler() {

		RoleBasedAuthenticationSuccessRedirectHandler successHandler = new RoleBasedAuthenticationSuccessRedirectHandler();

		return successHandler;
	}

}
